clear all
cap close
set more off
set mem 800m

cd ".\Data_Program"

* Figure 5(a) Capital-ratio-based IV

use beforereg_sci,clear

reg dfinshare2 cr08_wt bankshare hpgr popgr empgr fracy fracb subprime edu hpgr2 popgr2 empgr2 fracy2 fracb2 subprime2 edu2 dfinad dfinad2 i.state [aw=w]
predict xhat,resid

reg cr08_wt2 cr08_wt bankshare hpgr popgr empgr fracy fracb subprime edu hpgr2 popgr2 empgr2 fracy2 fracb2 subprime2 edu2 dfinad dfinad2 i.state [aw=w]
predict zhat,resid
reg xhat zhat [aw=w]

xtile cat = zhat,nq(22)
sort cat
by cat: egen cat_m = mean(zhat)
by cat: egen x_cat_m    = mean(xhat)
by cat: keep if _n==1
drop if cat>=21   // outliers

twoway(scatter x_cat_m cat_m)(lfit x_cat_m cat_m,lwidth(0.2) lpattern(dash)),xlabel(-0.015(0.005)0.01,labsize(4)) ylabel(-0.004(0.004)0.008,labsize(4)) legend(off) graphregion(color(white)) title("") xtitle("T1 capital ratio in SCMs, 2008",size(5)) ytitle("SCM FinTech growth, 2008-2015",size(5)) scheme(s2color)


* Figure 5(b) Big4-share-based IV

use beforereg_sci,clear

reg dfinshare2 cr08_wt bankshare hpgr popgr empgr fracy fracb subprime dfinad edu hpgr2 popgr2 empgr2 fracy2 fracb2 subprime2  dfinad2 edu2 i.state [aw=w]
predict xhat,resid

reg big4share_wt2 cr08_wt bankshare hpgr popgr empgr fracy fracb subprime dfinad edu hpgr2 popgr2 empgr2 fracy2 fracb2 subprime2  dfinad2 edu2 i.state [aw=w]
predict zhat,resid

xtile cat = zhat,nq(20)
sort cat
by cat: egen cat_m = mean(zhat)
by cat: egen x_cat_m    = mean(xhat)
by cat: keep if _n==1

twoway(scatter x_cat_m cat_m)(lfit x_cat_m cat_m,lwidth(0.2) lpattern(dash)),xlabel(-0.07(0.035)0.105,labsize(4)) ylabel(-0.005(0.005)0.011,labsize(4)) legend(off) graphregion(color(white)) title("") xtitle("Big4 share in SCMs, 2008",size(5)) ytitle("SCM FinTech growth, 2008-2015",size(5)) scheme(s2color)

